package day06;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Predicate;

public class Student {


    private void getName(String name, Consumer<String> consumer) {
        consumer.accept(name);
    }

    public void setName(String name) {
        getName(name, arg -> System.out.println("name:" + name));
    }

    public void checkName() {
        List<String> list = Arrays.asList("背景", "大一", "沃夫", "大师");
        List<String> cityList = getCityList(list, s -> s.contains("大"));
        System.out.println(cityList);
    }

    private List<String> getCityList(List<String> list, Predicate<String> predicate) {
        ArrayList<String> filter = new ArrayList<>();
        for (String f : list) {
            if (predicate.test(f)) {
                filter.add(f);
            }
        }
        return filter;
    };

}
